//客户端
//editor和host主进程【运行时】之间传消息
export class Host {

    ws: WebSocket;

    start() {
        const ws = new WebSocket('ws://localhost:1234');
        this.ws = ws;
        return new Promise<void>((resolve, reject) => {
            ws.onopen = () => {
                ws.send(JSON.stringify({
                    "command": "login",
                    "id": "runtime"
                }));
                resolve();
            }
        })
    }
    //
    send(data: any) {
        data.id = 'runtime';
        this.ws.send(JSON.stringify(data))
    }
}

